home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 197_01 / boxmac.cmd < prev    next >
OS/2 REXX Batch file  |  1980-01-01  |  12KB  |  590 lines

  1. ;    BOXMAC.CMD:    Standard Micro Startup Box drawing macroes
  2. ;            for MicroEMACS 3.9
  3. ;            (C)opyright 1987 by Suresh Konda and Daniel M Lawrence
  4. ;            Last Update: 07/12/87
  5.  
  6. write-message "[Loading Box Macroes]"
  7.  
  8. ;this macro inserts enough characters at the end of line to lineup with point
  9. store-procedure mvtopcol
  10. ;set $debug TRUE
  11.     end-of-line
  12.     set %temp &sub %pcol $curcol
  13.     !if &less $curcol %pcol
  14.     ;;    current position to left of point -- blank fill to point
  15.     ;    !if &gre %temp 0
  16.             %temp    insert-string " "
  17.     ;    !endif
  18.     !else
  19.         !if &less %temp 0
  20.             set %temp &neg %temp
  21.             %temp backward-character
  22.         !else
  23.             %temp forward-character
  24.         !endif
  25.     !endif
  26. !endm
  27. ;this macro inserts enough characters at the end of line to lineup with mark
  28. store-procedure mvtomcol
  29. ;set $debug TRUE
  30.     end-of-line
  31.     !if &less %mcol $curcol
  32.     ;;    current position to right of mark -- move to mark
  33. ;        insert-string &cat &cat %mcol " " $curcol
  34.         beginning-of-line
  35.         %mcol forward-character
  36.     !else
  37.     ;;      current position is to left of mark -- blank fill
  38.         set %temp &sub %mcol $curcol
  39.         !if &gre %temp 0
  40.             %temp insert-string " "
  41.         !endif
  42.     !endif
  43. !endm
  44.  
  45. store-procedure inschar
  46.     !if &equal %char 205
  47.         insert-string &chr %c1
  48.     !else
  49.         !if &equal %char 196
  50.             insert-string &chr %c2
  51.         !else
  52.             insert-string &chr %c3
  53.         !endif
  54.     !endif
  55. !endm
  56. store-procedure box2
  57. ;remember point
  58.     set %pcol &add $curcol 1
  59.     set %pline $curline
  60.     exchange-point-and-mark
  61. ;remember mark
  62. ;    set %mcol &add $curcol 1
  63.     set %mcol $curcol
  64.     set %mline $curline
  65. ;draw top horizontal line
  66.     insert-string "╔"
  67.     set %width &sub &sub %pcol %mcol 1
  68.     %width insert-string "═"
  69.      insert-string "╗"
  70.     newline-and-indent
  71. ;    insert-string " "
  72. ;draw bottom horizontal line
  73.     %pline goto-line
  74. ; we are now one line above old last line because of insertion of top line
  75.     next-line
  76.     end-of-line
  77.     newline
  78.     run mvtomcol
  79.     insert-string "╚"
  80.     %width insert-string "═"
  81.     insert-string "╝"
  82. ; bump pline 
  83. set %pline &add %pline 1
  84. ;draw verticals
  85.     %mline goto-line
  86. ;we are at top -- draw verticals
  87. *lp1
  88.     next-line
  89.     run mvtomcol
  90.     insert-string "║"
  91.     run mvtopcol
  92.     insert-string "║"
  93.     !if &less $curline %pline
  94.         !goto lp1
  95.     !endif
  96. ;return to point
  97.     %pline goto-line
  98.     next-line
  99.     beginning-of-line
  100.     %width forward-character
  101.     2 forward-character
  102. !endm
  103. store-procedure setpoints
  104. ;; procedure will set pcol, pline, mcol and mline
  105. set %pcol $curcol
  106. set %pline $curline
  107. exchange-point-and-mark
  108. set %mcol $curcol
  109. set %mline $curline
  110. exchange-point-and-mark
  111. !endm
  112.  
  113. ;; user procedure to draw a double line from mark to point making spaces for
  114. ;; the characters.
  115. store-procedure line2
  116. run setpoints
  117. !if &equal %pcol %mcol
  118.     run vert2
  119. !else
  120.     !if &equal %pline %mline
  121.         run hor2
  122.     !else
  123.         write-message "Illegal point and mark for lines"
  124.     !endif
  125. !endif
  126. !endm
  127.  
  128. ;; user procedure to draw line from mark to point making spaces for
  129. ;; the characters.
  130. store-procedure line1
  131. run setpoints
  132. !if &equal %pcol %mcol
  133.     run vert1
  134. !else
  135.     !if &equal %pline %mline
  136.         run hor1
  137.     !else
  138.         write-message "Illegal point and mark for lines"
  139.     !endif
  140. !endif
  141. !endm
  142.  
  143. store-procedure hor2
  144. ;; procedure to draw a double line from beginning of line to point
  145. ;; assume that the current line is to be double underlined.  pcol,mcol,pline,
  146. ;; mline already set by calling macro
  147. !if &equal %mcol %pcol
  148.     write-message "in hor equal cols"
  149.     !return
  150. !endif
  151. !if &less %pcol %mcol
  152. ;    then point was to left of mark.  exchange and reset variables
  153.     exchange-point-and-mark
  154.     run setpoints
  155. !endif
  156. end-of-line
  157. newline
  158. ;; move to under mark
  159. !if &greater %mcol 1
  160.     %mcol insert-string " "
  161. !endif
  162. ;; see if first char is a vertical line
  163. previous-line
  164. set %char  $curchar
  165. next-line
  166. !if &equ %char 186
  167.         insert-string "╠"
  168. !else
  169.     !if &equ %char 179 
  170.         insert-string "╞"
  171.     !else
  172.         insert-string "═"
  173.     !endif
  174. !endif
  175.  
  176. ; now for all chars but the last character i.e., char at point
  177. *lp1
  178.     previous-line
  179.     set %char  $curchar
  180.     next-line
  181.     !if &equ %char 186
  182.         insert-string "╬"
  183.         !else 
  184.         !if &equ %char 179
  185.             insert-string "╪"
  186.         !else
  187.             insert-string "═"
  188.         !endif
  189.     !endif
  190.     !if &less $curcol %pcol
  191.         !goto lp1
  192.     !endif
  193. ;; see if last char is a vertical line
  194. previous-line
  195. set %char  $curchar
  196. next-line
  197. !if &equ %char 186
  198.         insert-string "╣"
  199. !else
  200.     !if &equ %char 179 
  201.         insert-string "╡"
  202.     !else
  203.         insert-string "═"
  204.     !endif
  205. !endif
  206. !endm
  207.  
  208. store-procedure hor1
  209. ;; procedure to draw a single line from beginning of line to point
  210. !if &equal %mcol %pcol
  211.     write-message "in hor equal cols"
  212.     !return
  213. !endif
  214. !if &less %pcol %mcol
  215. ;    then point was to left of mark.  exchange and reset variables
  216.     exchange-point-and-mark
  217.     run setpoints
  218. !endif
  219. end-of-line
  220. newline
  221. ;; move to under mark
  222. !if &greater %mcol 1
  223.     %mcol insert-string " "
  224. !endif
  225. ;; see if first char is a vertical line
  226. previous-line
  227. set %char  $curchar
  228. next-line
  229. !if &equ %char 186
  230.         insert-string "╟"
  231. !else
  232.     !if &equ %char 179 
  233.         insert-string "├"
  234.     !else
  235.         insert-string "─"
  236.     !endif
  237. !endif
  238.  
  239. ; now for all chars but the last character i.e., char at point
  240. *lp1
  241.     previous-line
  242.     set %char  $curchar
  243.     next-line
  244.     !if &equ %char 186
  245.         insert-string "╫"
  246.         !else 
  247.         !if &equ %char 179
  248.             insert-string "┼"
  249.         !else
  250.             insert-string "─"
  251.         !endif
  252.     !endif
  253.     !if &less $curcol %pcol
  254.         !goto lp1
  255.     !endif
  256. ;; see if last char is a vertical line
  257. previous-line
  258. set %char  $curchar
  259. next-line
  260. !if &equ %char 186
  261.         insert-string "╢"
  262. !else
  263.     !if &equ %char 179 
  264.         insert-string "┤"
  265.     !else
  266.         insert-string "─"
  267.     !endif
  268. !endif
  269. !endm
  270.  
  271. store-procedure vert2
  272. ;; procedure to draw a line from mark to point.  mark should be above point
  273. ;; this will insert a column of double lines
  274. !if &equal %mline %pline
  275.     !return
  276. !endif
  277. !if &less %pline %mline
  278. ;    then point was above mark.  exchange and reset variables
  279.     exchange-point-and-mark
  280.     run setpoints
  281. !endif
  282. ;top line
  283. %mline goto-line
  284. beginning-of-line
  285. run mvtopcol
  286. backward-character
  287. set %char $curchar
  288. forward-character
  289.  
  290. !if &equal %char 205
  291.     insert-string "╦"
  292. !else
  293.     !if &equal %char 196
  294.         insert-string "╥"
  295.     !else
  296.         insert-string "║"
  297.     !endif
  298. !endif
  299. ;all but pline
  300. *lp1
  301.     next-line
  302.     beginning-of-line
  303.     run mvtopcol
  304.     backward-character
  305.     set %char $curchar
  306.     forward-character
  307.     !if &equal %char 205
  308.         insert-string "╬"
  309.     !else
  310.         !if &equal %char 196
  311.             insert-string "╫"
  312.         !else
  313.             insert-string "║"
  314.         !endif
  315.     !endif
  316.     !if &less $curline &sub %pline 1
  317.         !goto lp1
  318.     !endif
  319. ; bottom line
  320. next-line
  321. beginning-of-line
  322. run mvtopcol
  323. backward-character
  324. set %char $curchar
  325. forward-character
  326. !if &equal %char 205
  327.     insert-string "╩"
  328. !else
  329.     !if &equal %char 196
  330.         insert-string "╨"
  331.     !else
  332.         insert-string "║"
  333.     !endif
  334. !endif
  335. !if &less $curcol &sub %pcol 1
  336.     !goto lp1
  337. !endif
  338. !endm
  339.  
  340. store-procedure vert1
  341. ;; procedure to draw a line from mark to point.  mark should be above point
  342. ;; this will insert a column of double lines
  343. !if &equal %mline %pline
  344.     !return
  345. !endif
  346. !if &less %pline %mline
  347. ;    then point was above mark.  exchange and reset variables
  348.     exchange-point-and-mark
  349.     run setpoints
  350. !endif
  351. ;top line
  352. %mline goto-line
  353. beginning-of-line
  354. run mvtopcol
  355. backward-character
  356. set %char $curchar
  357. forward-character
  358.  
  359. !if &equal %char 205
  360.     insert-string "╤"
  361. !else
  362.     !if &equal %char 196
  363.         insert-string "┬"
  364.     !else
  365.         insert-string "│"
  366.     !endif
  367. !endif
  368. ;all but pline
  369. *lp1
  370.     next-line
  371.     beginning-of-line
  372.     run mvtopcol
  373.     backward-character
  374.     set %char $curchar
  375.     forward-character
  376.     !if &equal %char 205
  377.         insert-string "╪"
  378.     !else
  379.         !if &equal %char 196
  380.             insert-string "┼"
  381.         !else
  382.             insert-string "│"
  383.         !endif
  384.     !endif
  385.     !if &less $curline &sub %pline 1
  386.         !goto lp1
  387.     !endif
  388. ; bottom line
  389. next-line
  390. beginning-of-line
  391. run mvtopcol
  392. backward-character
  393. set %char $curchar
  394. forward-character
  395. !if &equal %char 205
  396.     insert-string "╧"
  397. !else
  398.     !if &equal %char 196
  399.         insert-string "┴"
  400.     !else
  401.         insert-string "│"
  402.     !endif
  403. !endif
  404. !if &less $curcol &sub %pcol 1
  405.     !goto lp1
  406. !endif
  407. !endm
  408.  
  409.  
  410. ;; user procedure to insert blanks from mark to point